package com.aaa.dao.impl;

import java.util.List;
import java.util.Map;

import com.aaa.dao.UserDAO;
import com.aaa.util.DAOUtil;

public class UserDAOImpl implements UserDAO{

	@Override
	public Map<String, Object> isLogin(Map<String, Object> args) {
		
		String sql = "select  *  from  user where telephone = ? and  password = ?";
		List<Map<String, Object>> list = DAOUtil.executeQuery(sql, args.get("u") ,  args.get("p")   );
		
		if(list.size() > 0) {
			return  list.get(0);
		}
		return null;
	}
	@Override
	public boolean isExist(Map<String, Object> args) {
		String sql = "select  *  from user where telephone = ?";
		List<Map<String, Object>> list = DAOUtil.executeQuery(sql, args.get("telephone"));
		return     list.size() > 0;
	}

	@Override
	public int saveUser(Map<String, Object> args) {
		String sql = "insert into user values (null,?,?,?,?)";
		return DAOUtil.executeUpdate(sql, args.get("telephone") , args.get("password"), args.get("email"), args.get("nickname"));
	}


}
